maintainer="Michał Polański <michal@polanski.me>"
pkgname=borgmatic
pkgver=1.9.0
pkgrel=0
pkgdesc="Simple, configuration-driven backup software for servers and workstations"
url="https://torsion.org/borgmatic/"
license="GPL-3.0-or-later"
arch="noarch"
depends="
	borgbackup
	py3-colorama
	py3-jsonschema
	py3-packaging
	py3-requests
	py3-ruamel.yaml
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="
	apprise
	py3-flexmock
	py3-pytest
	py3-pytest-cov
	"
subpackages="$pkgname-bash-completion $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://projects.torsion.org/borgmatic-collective/borgmatic/archive/$pkgver.tar.gz"
builddir="$srcdir/borgmatic"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2

	python3 -m venv --clear --without-pip --system-site-packages .venv
	.venv/bin/python3 -m installer \
		.dist/borgmatic-$pkgver-py3-none-any.whl
	.venv/bin/borgmatic --bash-completion >$pkgname.bash
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	PATH="$PATH:$builddir/.testenv/bin" .testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/borgmatic-$pkgver-py3-none-any.whl

	install -Dm644 $pkgname.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
}

sha512sums="
2d54a294748bf6a599d6d2a0b4e272f936e53d3a50104c1f5f680524df65b3e0cd7e8e2f80f8316d86e88a341e47621e6e65a2221a77e2d5636a0643fc66010c  borgmatic-1.9.0.tar.gz
"
